//
//  DaogAndJianzViewController.m
//  JiuKuGospel
//
//  Created by jiukuyinyue on 16/8/1.
//  Copyright (c) 2016年 JiuKuForApp. All rights reserved.
//

#import "DaogAndJianzViewController.h"

@interface DaogAndJianzViewController ()<UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong)UITableView * typeTab;

@property (nonatomic, strong)NSArray * typeArr;


@end

@implementation DaogAndJianzViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    //导航栏字体颜色
    self.navigationItem.title = @"祷告见证";
    self.typeArr = [NSArray arrayWithObjects:@"祷告", @"见证", nil];
    [self setupUI];
}

- (void)setupUI
{
    self.typeTab = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height) style:UITableViewStylePlain];
    _typeTab.delegate = self;
    _typeTab.dataSource = self;
    [self.view addSubview:_typeTab];
    
    //cell分割线顶头
    if ([self.typeTab respondsToSelector:@selector(setSeparatorInset:)]) {
        [self.typeTab setSeparatorInset: UIEdgeInsetsZero];
    }
    if ([self.typeTab respondsToSelector:@selector(setLayoutMargins:)]) {
        [self.typeTab setLayoutMargins: UIEdgeInsetsZero];
    }
    [self setExtraCellLineHidden:_typeTab];

    
}

- (void)setExtraCellLineHidden: (UITableView *)tableView
{
    UIView *view = [[UIView alloc]init];
    view.backgroundColor = [UIColor clearColor];
    [tableView setTableFooterView:view];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.typeArr.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString * cellStr = @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellStr];
    }
    
    cell.textLabel.text = [self.typeArr objectAtIndex:indexPath.row];
    cell.textLabel.textAlignment = NSTextAlignmentCenter;
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    if (indexPath.row == 0) {       //祷告
        NSString *clzName = @"DaoGaoViewController";
        Class clz = NSClassFromString(clzName);//将字符串转化成class
        UIViewController *viewController = [[clz alloc] init];
        [self.navigationController pushViewController:viewController animated:YES];
        NSLog(@"祷告");
    }
    if (indexPath.row == 1) {       //见证
        NSString *clzName = @"JianZhengViewController";
        Class clz = NSClassFromString(clzName);//将字符串转化成class
        UIViewController *viewController = [[clz alloc] init];
        [self.navigationController pushViewController:viewController animated:YES];
        NSLog(@"见证");
    }
    if (indexPath.row == 2) {
        NSLog(@"暂无");
    }

    
}

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        
        [cell setSeparatorInset:UIEdgeInsetsZero];
        
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        
        [cell setLayoutMargins:UIEdgeInsetsZero];
    }
}

@end
